Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing calls to fail() when exceptions are expected to be thrown #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Pokechu22
Copy link

Fixes #106. Without this, the test could pass if no exception is thrown, in addition to the wanted result of a matching exception being thrown.

fail() is now called before any catch in test code, as verified by grep -B1 -r catch src/test/java:
src/test/java/com/mojang/brigadier/arguments/DoubleArgumentTypeTest.java-            fail();
src/test/java/com/mojang/brigadier/arguments/DoubleArgumentTypeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/arguments/DoubleArgumentTypeTest.java-            fail();
src/test/java/com/mojang/brigadier/arguments/DoubleArgumentTypeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/arguments/FloatArgumentTypeTest.java-            fail();
src/test/java/com/mojang/brigadier/arguments/FloatArgumentTypeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/arguments/FloatArgumentTypeTest.java-            fail();
src/test/java/com/mojang/brigadier/arguments/FloatArgumentTypeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/arguments/IntegerArgumentTypeTest.java-            fail();
src/test/java/com/mojang/brigadier/arguments/IntegerArgumentTypeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/arguments/IntegerArgumentTypeTest.java-            fail();
src/test/java/com/mojang/brigadier/arguments/IntegerArgumentTypeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/arguments/LongArgumentTypeTest.java-            fail();
src/test/java/com/mojang/brigadier/arguments/LongArgumentTypeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/arguments/LongArgumentTypeTest.java-            fail();
src/test/java/com/mojang/brigadier/arguments/LongArgumentTypeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java-            fail();
src/test/java/com/mojang/brigadier/CommandDispatcherTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/StringReaderTest.java-            fail();
src/test/java/com/mojang/brigadier/StringReaderTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/tree/LiteralCommandNodeTest.java-            fail();
src/test/java/com/mojang/brigadier/tree/LiteralCommandNodeTest.java:        } catch (final CommandSyntaxException ex) {
--
src/test/java/com/mojang/brigadier/tree/LiteralCommandNodeTest.java-            fail();
src/test/java/com/mojang/brigadier/tree/LiteralCommandNodeTest.java:        } catch (final CommandSyntaxException ex) {

Fixes Mojang#106.  Without this, the test could pass if no exception is thrown, in addition to the wanted result of a matching exception being thrown.
@peterix
Copy link
Contributor

peterix commented Oct 26, 2022

Closing and reopening to rerun checks.

@peterix peterix closed this Oct 26, 2022
@peterix peterix reopened this Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests (where relevant) don't actually make sure that an exception was thrown.
5 participants